/**
 * dashboard service
 */
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';

import { List } from './model.dashboard.list';

@Injectable()
export class DashboardService {
    listUrl = '/api/list';
    constructor(private http: Http) {

    }
    getLists(): Observable<List[]> {
        return this.http.get(this.listUrl)
            .map(this.handle)
            .catch(this.catch);
    }

    private handle(resp: Response): any {
        let body = resp.json();
        return body.result || {};
    }

    private catch(error: Response | any) {
        return Observable.throw(error);
    }
}